let qs = require('qs')

// app.ts
App({
  globalData: {},
  onLaunch() {
    wx.cloud.init({
      env: 'punch-card-1g0n088q6c3b0bf5',
      traceUser: true
    })
    if(wx.getStorageSync('openId')) return
    this.updateUserInfo()
  },

  updateUserInfo(): Promise<any> {
    return new Promise(resolve => {
      wx.cloud.callFunction({
        name: 'getUserInfo',
        success: (res: any) => {
          wx.setStorageSync('openId', res.result.userInfo.openId)
          resolve(res)
        }
      })
    })
  }
})
